import Joi from '@hapi/joi';
import { paginateRule } from '../common';

export const indexRule = {
  query: {
    name: Joi.string().trim().allow(''),
    domain: Joi.string().trim().allow(''),
    id: Joi.string().trim(),
    ...paginateRule,
  },
};


export const createRule = {
  body: {
    name: Joi.string()
      .trim()
      .required(),
    domain: Joi.string()
      .trim()
      .required(),
  },
};

export const updateRule = {
  params: {
    id: Joi.string(),
  },
  body: createRule.body
};

export const destroyRule = {
  params: {
    id: Joi.string(),
  },
};

export const configRule = {
  body: {
    name: Joi.string()
      .trim(),
    domain: Joi.string()
      .trim(),
    address: Joi.string()
      .trim(),
    about: Joi.string()
      .trim(),
    appid: Joi.string()
      .trim(),
    secret: Joi.string()
      .trim(),
    phone: Joi.string()
      .trim(),
    partner_key: Joi.string()
      .trim(),
    pay_tips: Joi.string()
      .trim(),
    mchid: Joi.string()
      .trim(),
    fei_user: Joi.string()
      .trim(),
    fei_ukey: Joi.string()
      .trim(),
    fei_sn: Joi.string()
      .trim(),
    tableware: Joi.number(),
    pack: Joi.number(),
    logo: Joi.string()
      .trim(),
    type: Joi.string()
      .trim()
  },
};

export const getUserRule = {
  params: {
    id: Joi.string(),
  },
};


export const setUserRule = {
  params: {
    id: Joi.number(),
  },
  body: {
    idList: Joi.array()
      .items(Joi.number())
      .required(),
  },
};